/*
 * @Author: David Ma
 * @FilePath: \huaxia-real-estate-web\src\api\user.ts
 * @LastEditors: David Ma
 * @Description: 该文件用于
 * @Date: 2024-01-01 18:03:05
 */
import { UserState } from '@/store/modules/user/types';
import instance from "@/utils/request";

export interface LoginData {
    userName: string;
    userPassword: string;
    code: string;
}
export interface RegisterData {
    username: string;
    email: string;
    password: string
    code: string;
}

export interface LoginRes {
    tokenValue: string;
}

export function login(data: LoginData) {
    return instance.post('/api/user/login/' + data.code, data);
}
export function logout() {
    return instance.post<LoginRes>('/api/user/logout');
}
export function registerSendCode(data: RegisterData) {
    return instance.post('/api/user/simple/' + data.email);
}
export function registerVerification(data: RegisterData) {
    return instance.post('/api/user/verification/' + data.email + '/' + data.code);
}
export function register(data: RegisterData) {
    return instance.post('/api/user/register', data);
}
export function getUserInfo() {
    return instance.get<UserState>('/api/user/info');
}
